package com.twotiger.and.bean;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import com.twotiger.and.util.DateUtil;
import com.twotiger.and.util.LogUtil;

/**
 * 项目详情
 * @author gao
 *
 */
public class DebtProjectdetailData extends Order implements Serializable {
    private int repaymentType; //还款方式    repaymentType   Integer 是   
    private String endInterestDate;//结束还款时间  endInterestDate String(17)  是   
    private String loanPeopleSimple;//借款人信息(简略)   loanPeopleSimple    String  是   详情概略使用
    private String loanUseSimple;//借款用途(简略)    loanUseSimple   String  是   详情概略使用
    private String repaymentWaySimple;//  还款来源(简略)    repaymentWaySimple  String  是   详情概略使用
    private String certAuditSimple;// 资质审核(简略)    certAuditSimple String  是   详情概略使用
    private String loanUse;//  借款用途    loanUse String  是   
    private String repaymentWay;//  还款来源    repaymentWay    String  是   
    private String repaymentList;//还款计划集合  repaymentList   Json    是   数据集合
    private String investList;//投资记录集合  investList  Json    是   数据集合
    private int investCount;// 投资人数    investCount Integer 是   
    private double investAmount;// 投资总额    investAmount    Double(20,2)    是   
    private String projectId;//项目标识

    private double orderamount; //投资金额  ---债权转让投资订单
    private double expectinterest; //预计收益
    private double dfInterest; //垫付利息 --债权预计
    private double assignAmount; //打折金额--债权预计

    private double inverstamount; //投资金额 
    
    private int allowAssign;
    
    private String pType; // 项目类型    pType   String  是   参考字典：调合同使用 ProjectType
    private String bId; //   转让项目标识  bId String(1,10)    是   项目唯一标示符
    private String name; //   名称  name    String(1,60)    是   
    private int investMark; //   可投标识    investMark  Integer 是   是否可投：0-不能 1-能
    private int discountMark; //   打折标识    discountMark    Integer 是   打折标识：0-无打折 1-有打折
    private double assignRate; //    打折率 assignRate  Double(20,2)    是   discountMark=1存在
    private double yield; //   转让利率    yield   Double(20,2)    是   
    private int remainDays; //   剩余天数    remainDays  Integer 是   
    private String bAmount; // 转让总额    bAmount String  是   
    private String remainAmount; //  剩余可投金额  remainAmount    String  是   
    private String completeLv; //  完成率 completeLv  String  是   
    private String assignMark; //    是否允许转让  assignMark  String  是   0-不允许；1-允许
    private String assignMsg; //   转让文案    assignMsg   String  否   assignMark=1存在
    private String pledgeType; //    抵押物类型   pledgeType  String  是   
    private int status; //     状态  status  Integer 是   参考字典：ProjectStatus
    private String statusName; // 状态中文    statusName  String  是   
    private double minInvest; //   最小投资额   minInvest   Double(20,2)    是   
    private double maxInvest; //   最大投资额   maxInvest   Double(20,2)    是   
    private String repayTypeName; //   还款方式名称  repayTypeName   String  是   
    private String startTime; //   开始时间    startTime   String(17)  是   开始时间
    private String deadline; //    截止时间    deadline    String(17)  是   截止时间
    private String systime; //    系统时间    systime String(17)  是   系统时间
    

    public String getpType() {
        return pType;
    }

    public void setpType(String pType) {
        this.pType = pType;
    }

    public String getAssignMark() {
        return assignMark;
    }

    public void setAssignMark(String assignMark) {
        this.assignMark = assignMark;
    }

    public String getPledgeType() {
        return pledgeType;
    }

    public void setPledgeType(String pledgeType) {
        this.pledgeType = pledgeType;
    }

    public String getRepayTypeName() {
        return repayTypeName;
    }

    public void setRepayTypeName(String repayTypeName) {
        this.repayTypeName = repayTypeName;
    }

    public int getAllowAssign() {
        return allowAssign;
    }

    public void setAllowAssign(int allowAssign) {
        this.allowAssign = allowAssign;
    }

    public String getAssignMsg() {
        return assignMsg;
    }

    public void setAssignMsg(String assignMsg) {
        this.assignMsg = assignMsg;
    }

    public int getInvestMark() {
        return investMark;
    }

    public void setInvestMark(int investMark) {
        this.investMark = investMark;
    }

    public double getInverstamount() {
        return inverstamount;
    }

    public void setInverstamount(double inverstamount) {
        this.inverstamount = inverstamount;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getDeadline() {
        return deadline;
    }

    public void setDeadline(String deadline) {
        this.deadline = deadline;
    }

    public String getbId() {
        return bId;
    }

    public void setbId(String bId) {
        this.bId = bId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getDiscountMark() {
        return discountMark;
    }

    public void setDiscountMark(int discountMark) {
        this.discountMark = discountMark;
    }

    public int getRemainDays() {
        return remainDays;
    }

    public void setRemainDays(int remainDays) {
        this.remainDays = remainDays;
    }

    public String getRemainAmount() {
        return remainAmount;
    }

    public void setRemainAmount(String remainAmount) {
        this.remainAmount = remainAmount;
    }

    public double getYield() {
        return yield;
    }

    public void setYield(double yield) {
        this.yield = yield;
    }

    public String getCompleteLv() {
        return completeLv;
    }

    public void setCompleteLv(String completeLv) {
        this.completeLv = completeLv;
    }

    public int getRepaymentType() {
        return repaymentType;
    }

    public void setRepaymentType(int repaymentType) {
        this.repaymentType = repaymentType;
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getStatusName() {
        return statusName;
    }

    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }

    public String getSystime() {
        return systime;
    }

    public void setSystime(String systime) {
        this.systime = systime;
    }

    public String getbAmount() {
        return bAmount;
    }

    public void setbAmount(String bAmount) {
        this.bAmount = bAmount;
    }

    public double getAssignRate() {
        return assignRate;
    }

    public void setAssignRate(double assignRate) {
        this.assignRate = assignRate;
    }

    public double getMinInvest() {
        return minInvest;
    }

    public void setMinInvest(double minInvest) {
        this.minInvest = minInvest;
    }

    public double getMaxInvest() {
        return maxInvest;
    }

    public void setMaxInvest(double maxInvest) {
        this.maxInvest = maxInvest;
    }

    public String getEndInterestDate() {
        return endInterestDate;
    }

    public void setEndInterestDate(String endInterestDate) {
        this.endInterestDate = endInterestDate;
    }

    public String getLoanPeopleSimple() {
        return loanPeopleSimple;
    }

    public void setLoanPeopleSimple(String loanPeopleSimple) {
        this.loanPeopleSimple = loanPeopleSimple;
    }

    public String getLoanUseSimple() {
        return loanUseSimple;
    }

    public void setLoanUseSimple(String loanUseSimple) {
        this.loanUseSimple = loanUseSimple;
    }

    public String getRepaymentWaySimple() {
        return repaymentWaySimple;
    }

    public void setRepaymentWaySimple(String repaymentWaySimple) {
        this.repaymentWaySimple = repaymentWaySimple;
    }

    public String getCertAuditSimple() {
        return certAuditSimple;
    }

    public void setCertAuditSimple(String certAuditSimple) {
        this.certAuditSimple = certAuditSimple;
    }

    public String getLoanUse() {
        return loanUse;
    }

    public void setLoanUse(String loanUse) {
        this.loanUse = loanUse;
    }

    public String getRepaymentWay() {
        return repaymentWay;
    }

    public void setRepaymentWay(String repaymentWay) {
        this.repaymentWay = repaymentWay;
    }


    public String getRepaymentList() {
        return repaymentList;
    }

    public void setRepaymentList(String repaymentList) {
        this.repaymentList = repaymentList;
    }

    public String getInvestList() {
        return investList;
    }

    public void setInvestList(String investList) {
        this.investList = investList;
    }

    public int getInvestCount() {
        return investCount;
    }

    public void setInvestCount(int investCount) {
        this.investCount = investCount;
    }

    public double getInvestAmount() {
        return investAmount;
    }

    public void setInvestAmount(double investAmount) {
        this.investAmount = investAmount;
    }

    public double getOrderamount() {
        return orderamount;
    }

    public void setOrderamount(double orderamount) {
        this.orderamount = orderamount;
    }

    public double getExpectinterest() {
        return expectinterest;
    }

    public void setExpectinterest(double expectinterest) {
        this.expectinterest = expectinterest;
    }

    public double getDfInterest() {
        return dfInterest;
    }

    public void setDfInterest(double dfInterest) {
        this.dfInterest = dfInterest;
    }

    public double getAssignAmount() {
        return assignAmount;
    }

    public void setAssignAmount(double assignAmount) {
        this.assignAmount = assignAmount;
    }


    /**倒计时*/
    private String time2Start;
    private long localSysTime = System.currentTimeMillis();

    public String getTime2Start() {
        LogUtil.info(ProjectDetail.class, deadline + " " + systime);
//        long t = Long.parseLong(deadline)
//                 - (Long.parseLong(systime) + System.currentTimeMillis() - localSysTime);
        long t = DateUtil.subDate((Long.parseLong(systime) + System.currentTimeMillis() - localSysTime) + "", deadline);
        if (t < 0) {
            time2Start = "已完成";
        } else {
            String[] tmps = secondToDate(t / 1000);
            time2Start = tmps[0] + "天" + tmps[1] + "小时" + tmps[2] + "分" + tmps[3] + "秒";
        }
        return time2Start;
    }

    public String[] secondToDate(long prt) {
        int dd = (int) (prt / 60 / 60 / 24); //计算剩余的天数
        int hh = (int) (prt / 60 / 60 % 24); //计算剩余的小时数
        int mm = (int) (prt / 60 % 60); //计算剩余的分钟数
        int ss = (int) (prt % 60); //计算剩余的秒数

        String dd1 = checkTime(dd);
        String hh1 = checkTime(hh);
        String mm1 = checkTime(mm);
        String ss1 = checkTime(ss);
        return new String[] { dd1, hh1, mm1, ss1 };
    }

    private String checkTime(int i) {
        String tmp = "";
        if (i < 10) {
            tmp = "0" + (i < 0 ? 0 : i);
        } else {
            tmp = i + "";
        }
        return tmp;
    }

}
